1 : <?php
2 : /*--------------------------------------------------------------------------+
3 : This file is part of eStudy
4 : externaltools/classes/class.toolspage.inc.php
5 : - Modulgruppe: ExternalTools
6 : - Beschreibung: Stellt eine Seite dar, die Zugriff auf externe Tools ermöglicht.
7 : - Version: 0.1 23/04/05
8 : - Autor(en): Christian Gerhardt <case42@gmx.net>
9 : +---------------------------------------------------------------------------+
10 : This program is free software; you can redistribute it and/or
11 : modify it under the terms of the GNU General Public License
12 : as published by the Free Software Foundation; either version 2
13 : of the License, or any later version.
14 : +---------------------------------------------------------------------------+
15 : This program is distributed in the hope that it will be useful,
16 : but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : GNU General Public License for more details.
19 : You should have received a copy of the GNU General Public License
20 : along with this program; if not, write to the Free Software
21 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 : +--------------------------------------------------------------------------*/
23 : /**
24 : * Diese Datei enthällt die Klasse ToolsPage.
25 : * @package eStudy.ExternalTools
26 : * @version 1.0 13/10/05
27 : * @author Christian Gerhardt <case42@gmx.net>
28 : * @param char $_GET['ID'] - die link id
29 : */
30 1 : if (!defined('PATH_TO_ROOT'))
31 1 : define("PATH_TO_ROOT", "../../");
32 :
33 : /**Zur Verwaltung der einzelnen Tools.*/
34 1 : require_once ("class.externaltool.inc.php");
35 :
36 : /***/
37 1 : require_once ("class.ettools.inc.php");
38 :
39 : /**Um die allgemeinen Konstenten zu verwenden.*/
40 1 : require_once ("defines.inc.php");
41 :
42 : /**
43 : *
44 : * @package eStudy.ExternalTools
45 : * @version 0.1 23/04/05
46 : * @author Christian Gerhardt <case42@gmx.net>
47 : */
48 1 : class ToolsPage {
49 : /**
50 : *
51 : * @access private
52 : * @var integer
53 : */
54 : public $courseID;
55 :
56 : /**
57 : *
58 : * @access private
59 : * @var boolean
60 : */
61 : public $showAdminLink;
62 :
63 : /**
64 : *
65 : * @access private
66 : * @var array
67 : */
68 : public $toolsList;
69 :
70 : /**
71 : *
72 : * @access private
73 : * @var integer
74 : */
75 : public $id;
76 :
77 : /**
78 : *
79 : */
80 : public $action;
81 :
82 : public function ToolsPage($courseID, $showAdminLink = false) {
83 0 : $this->courseID = $courseID;
84 0 : $this->showAdminLink = $showAdminLink;
85 0 : $this->createPageList($showAdminLink);
86 0 : if (isset ($_GET['ID'])) {
87 0 : $this->id = $_GET['ID'];
88 0 : }
89 0 : elseif (isset ($_POST['ID'])) {
90 0 : $this->id = $_POST['ID'];
91 0 : } else {
92 0 : $this->id = null;
93 : }
94 0 : if (isset ($_GET['ACTION'])) {
95 0 : $this->action = $_GET['ACTION'];
96 0 : }
97 0 : elseif (isset ($_POST['ACTION'])) {
98 0 : $this->action = $_POST['ACTION'];
99 0 : } else {
100 0 : $this->action = null;
101 : }
102 0 : }
103 :
104 : /**
105 : *
106 : * @access public
107 : */
108 : public function echoMenu() {
109 0 : echo "<table style='width:100%;'>\n";
110 0 : echo "<tr>\n";
111 0 : $i = -1;
112 0 : foreach ($this->toolsList as $tool) {
113 0 : $i++;
114 0 : if (($i % 5) == 0) {
115 0 : echo "</tr>\n";
116 0 : echo "<tr>\n";
117 0 : }
118 0 : if ($this->id == $tool->getID()) {
119 0 : echo "<td width='20%' align='center'>";
120 0 : } else {
121 0 : echo "<td width='20%' align='center'>";
122 : }
123 0 : $tool->echoLink();
124 0 : echo "</td>\n";
125 0 : }
126 0 : while ($i % 5 != 0) {
127 0 : echo "<td width='20%' class='text12'> </td>\n";
128 0 : $i++;
129 0 : }
130 0 : echo "</tr>\n";
131 0 : echo "</table>\n";
132 0 : }
133 :
134 : /**
135 : *
136 : * @access public
137 : */
138 : public function echoPage($method = "echoDefaultContent") {
139 0 : switch ($this->action) {
140 0 : case 'REGISTER' :
141 0 : $this->echoRegistrationForm();
142 0 : break;
143 :
144 0 : default :
145 0 : if ($this->id != null) {
146 0 : if (isset ($this->toolsList[$this->id])) {
147 0 : if ($this->toolsList[$this->id]->isRegistrationRequired()) {
148 0 : if ($this->toolsList[$this->id]->getUserRegisterStatus($_SESSION['userid'], $_SESSION['course']) != REGISTRATION_STATE_ACCEPTED) {
149 0 : $this->echoRegistrationForm();
150 0 : break;
151 : }
152 0 : }
153 0 : if (!$this->toolsList[$this->id]->showInOwnWindow) {
154 0 : $this->echoMenu();
155 0 : }
156 0 : $this->toolsList[$this->id]->echoPage();
157 0 : break;
158 : }
159 0 : }
160 0 : call_user_func(array (
161 0 : $this,
162 : $method
163 0 : ));
164 0 : }
165 0 : }
166 :
167 : public function echoRegistrationForm() {
168 : /***/
169 0 : require_once (PATH_TO_ROOT . "externaltools/classes/class.register.inc.php");
170 0 : $register = new Register($this->toolsList[$this->id]);
171 0 : $register->doIt();
172 0 : }
173 :
174 : /**
175 : *
176 : * @access public
177 : */
178 : public function echoAdminContent() {
179 : /*Für die Administrations Seite*/
180 0 : require_once (PATH_TO_ROOT . "externaltools/classes/class.adminpage.inc.php");
181 0 : $adminpage = new AdminPage($this->toolsList);
182 0 : $adminpage->echoPage();
183 0 : }
184 :
185 : /**
186 : *
187 : * @access public
188 : */
189 : public function echoSettingsContent() {
190 : /*Für die Administrations Seite*/
191 0 : require_once (PATH_TO_ROOT . "externaltools/classes/class.settingspage.inc.php");
192 0 : $adminpage = new SettingsPage();
193 0 : $adminpage->echoPage();
194 0 : }
195 :
196 : /**
197 : *
198 : */
199 : public function showInOwnWindow() {
200 0 : if ($this->id != null) {
201 0 : if (isset ($this->toolsList[$this->id]) && is_object($this->toolsList[$this->id])) {
202 0 : if ($this->toolsList[$this->id]->isRegistrationRequired()) {
203 0 : if ($this->toolsList[$this->id]->getUserRegisterStatus($_SESSION['userid'], $_SESSION['course']) != REGISTRATION_STATE_ACCEPTED) {
204 0 : return false;
205 : }
206 0 : }
207 0 : if (isset ($this->toolsList[$this->id]->tools[$this->toolsList[$this->id]->type]) && is_object($this->toolsList[$this->id]->tools[$this->toolsList[$this->id]->type])) {
208 0 : if (is_null($this->toolsList[$this->id]->tools[$this->toolsList[$this->id]->type]->getUserLoginData($_SESSION['userid']))) {
209 0 : return false;
210 : }
211 0 : }
212 0 : } else {
213 0 : return false;
214 : }
215 0 : return $this->toolsList[$this->id]->showInOwnWindow;
216 : }
217 0 : return false;
218 : }
219 :
220 : /**
221 : *
222 : * @access private
223 : */
224 : public function createPageList() {
225 0 : global $db, $settings;
226 0 : $this->toolsList = array ();
227 0 : $usergroup = isset($_SESSION['usergroup']) ? $_SESSION['usergroup'] : STUDENT;
228 : switch ($usergroup) {
229 0 : case ADMIN :
230 0 : $accessSettings = SIGNUP_NO_RESTRICTIONS;
231 0 : break;
232 :
233 0 : case STUDENT :
234 0 : case ALUMNUS:
235 0 : case SCHUELER:
236 0 : case GAST:
237 0 : $accessSettings = SIGNUP_ONLY_STUDENTS;
238 0 : break;
239 :
240 0 : case DOZENT :
241 0 : $accessSettings = SIGNUP_ONLY_TEACHERS;
242 0 : break;
243 :
244 0 : case SEKRETARIAT :
245 0 : $accessSettings = SIGNUP_ONLY_ASSISTENTS;
246 0 : break;
247 : }
248 : // $query = "SELECT toolID, courseID, description, userSignupSettings, toolOptions FROM %set_tools WHERE courseID ='%s'";
249 : // $query = sprintf($query,
250 : // $settings['dbPrefix'],
251 : // $this->courseID);
252 : // $tools = $db->get_results($query, ARRAY_A);
253 : // if(count($tools) > 0){
254 : // foreach($tools as $tool){
255 : // if(($accesSettings & $tool['userSignupSettings']) == $accesSettings){
256 : // $query = "SELECT * FROM %set_tooldata WHERE ID='%s'";
257 : // $query = sprintf($query,
258 : // $settings['dbPrefix'],
259 : // $tool['toolID']);
260 : // $toolData = $db->get_row($query, ARRAY_A);
261 : // $this->toolsList[$tool['toolID']] = new ExternalTool(array_merge($tool, $toolData));
262 : // }
263 : // }
264 : // }
265 0 : $this->toolsList = ETTools :: getExternalToolList($this->courseID, $accessSettings);
266 0 : }
267 :
268 : /**
269 : *
270 : * @access private
271 : */
272 : public function echoDefaultContent() {
273 0 : echo "<div>\n";
274 0 : echo "<h2>";
275 0 : echo "Hier finden Sie Links zu externen Werkzeugen.\n";
276 0 : echo "</h2>\n";
277 0 : echo "</div>\n";
278 0 : echo "<div>\n";
279 0 : $this->echoToolList();
280 0 : echo "</div>\n";
281 0 : }
282 :
283 : /**
284 : *
285 : */
286 : public function echoToolList() {
287 0 : if (count($this->toolsList)) {
288 0 : echo "<table id='Werkzeugliste'>\n";
289 0 : foreach ($this->toolsList as $toolSettings) {
290 0 : echo "<tr>\n";
291 0 : echo "<td class='tableBorder'>\n";
292 0 : $toolSettings->echoLink();
293 0 : echo "</td>\n";
294 0 : echo "<td class='tableBorder' style='width:100%;'>\n";
295 0 : $toolSettings->echoDescription();
296 0 : echo "</td>\n";
297 0 : if ( $toolSettings->isRegistrationRequired() ) {
298 0 : echo "<td class='tableBorder' >\n";
299 0 : $this->echoRegistrationLink($toolSettings->getID(), $toolSettings->getUserRegisterStatus($_SESSION['userid'], $_SESSION['course']));
300 0 : echo "</td>\n";
301 0 : }
302 : // Trage Benutzer in die Tools ein, falls noch nicht geschehen
303 0 : $toolSettings->logonUserToTool( $_SESSION['userid'] );
304 0 : echo "</tr>\n";
305 0 : }
306 0 : echo "</table>\n";
307 0 : } else {
308 0 : echo "Leider sind zur Zeit keine externen Werkzeuge angelegt.";
309 : }
310 0 : }
311 :
312 : /**
313 : *
314 : */
315 : public function echoRegistrationLink($toolid, $registerStatus) {
316 0 : $linkString = "<a href='%s?ID=%s&ACTION=REGISTER'>%s</a>";
317 : switch ($registerStatus) {
318 0 : case REGISTRATION_STATE_WAITING :
319 0 : printf($linkString, PATH_TO_ROOT . SCRIPT_NAME, $toolid, "Wartend");
320 0 : break;
321 :
322 0 : case REGISTRATION_STATE_ACCEPTED :
323 0 : echo "Registriert";
324 0 : break;
325 :
326 0 : case REGISTRATION_STATE_REFUSED :
327 0 : case REGISTRATION_STATE_REFUSED_FINALLY :
328 0 : printf($linkString, PATH_TO_ROOT . SCRIPT_NAME, $toolid, "Abgelehnt");
329 0 : break;
330 :
331 0 : default :
332 0 : printf($linkString, PATH_TO_ROOT . SCRIPT_NAME, $toolid, "Registrieren");
333 0 : }
334 0 : }
335 : }
|